package com.dreamthen.controller;

import com.dreamthen.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Author zengms
 * @Date 2023-11-05 10:29:33
 **/
@Controller
@RequestMapping("/rest")
public class RestController {

    /**
     * 查询
     *
     * @return
     */
    @GetMapping("/rest01/{id}")
    public String rest01(@PathVariable("id") String id) {
        System.out.println("****rest01-id" + id);
        return "forward:/index.jsp";
    }

    /**
     * 新增
     *
     * @return
     */
    @PostMapping("/rest02/user")
    public String rest02(User user) {
        System.out.println("****rest02-user" + user.toString());
        return "forward:/index.jsp";
    }

    /**
     * 修改
     *
     * @return
     */
    @PutMapping("/rest03/user/{id}")
    public String rest03(User user) {
        System.out.println("****rest03-user" + user.toString());
        return "forward:/index.jsp";
    }

    /**
     * 删除
     *
     * @return
     */
    @DeleteMapping("/rest04/{id}")
    public String rest04(@PathVariable("id") String id) {
        System.out.println("****rest04-id" + id);
        return "redirect:/index.jsp";
    }
}
